﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

using Microsoft.EntityFrameworkCore;


namespace WebApp.Services
{
    public class EfSqlLiteContextService : DbContext, IDataBaseService
    {
        private readonly DbConnectionConfigurationServicecs _dbConfig;

        public EfSqlLiteContextService(DbConnectionConfigurationServicecs dbConfig)
        {
            _dbConfig = dbConfig;
        }
        public DbSet<TestModel> TestModels { get; set; }
        
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlite(_dbConfig.DbConnection.SqlLite);
       
        }
        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.Entity<TestModel>().HasKey(m => m.Id);
            base.OnModelCreating(builder);
        }


    }



   [Table(name: "TestModel")]
    public class TestModel
    {
        [Key]
        public int Id { get; set; }
        public string Name { get; set; }

    }
}
